package cm.nougs.teamextension;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.ScheduleBuilder;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;
 
public class QuickQuartz {
    public static void main(String[] args) throws SchedulerException, InterruptedException {
        // start the Scheduler
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        scheduler.start();
 
        // create the Job
        JobDetail job = JobBuilder.newJob(QuickQuartzJob.class).
                withIdentity("QuickQuartzJob").build();
 
        // create the Schedule, run every 5 seconds
        ScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.
                simpleSchedule().
                withIntervalInSeconds(5).
                repeatForever();
 
        // create the Trigger
        Trigger trigger = TriggerBuilder.
                newTrigger().
                withIdentity("QuickQuartzTrigger").
                withSchedule(scheduleBuilder).
                startNow().build();
 
        // schedule the Job
        scheduler.scheduleJob(job, trigger);
 
        // run for 30 seconds and exit
        Thread.sleep(1000 * 60);
        scheduler.shutdown();
    }
}